<template>
  <div class="record-new">
    <el-form ref="newForm" :model="newForm" label-width="70px">
      <el-form-item label="续费：" prop="oneResponPersonName">
        <div class="flex">
          <div style="width: 40%" class="mr-10">
            <el-input placeholder="数量" type="text" v-model="newForm.number"></el-input>
          </div>
<!--          <el-select class="flex-1" v-model="newForm.unitProperty" placeholder="请选择">-->
          <el-select class="flex-1" v-model="newForm.time" placeholder="请选择">
<!--            <el-option :label="item.name" :value="item.id" v-for="(item,index) in unitList" :key="index"></el-option>-->
            <el-option value="天">天</el-option>
            <el-option value="月">月</el-option>
            <el-option value="年">年</el-option>
          </el-select>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { mapState } from 'vuex'
import Location from '@/components/census/record/Location.vue'
import Industry from '@/components/census/record/Industry.vue'
import UnitType from '@/components/census/record/UnitType.vue'
import FireDepartment from '@/components/census/record/FireDepartment.vue'
import IndustryAuthority from '@/components/census/record/IndustryAuthority.vue'
import Org from '@/components/census/record/Org.vue'
export default {
  name: 'renew',
  components: {
    Location,
    Industry,
    UnitType,
    FireDepartment,
    IndustryAuthority,
    Org
  },
  props: {
    activeData: {
      type: Object,
      default(){
        return null
      },
    }
  },
  computed: {
  },
  watch: {
    activeData () {
      this.initForm()
    },
  },
  data () {
    return {
      newForm: {
        time : '天'
      },
    }
  },
  methods: {
    submitAction () {
      this.$refs['newForm'].validate((valid) => {
        if (valid) {
          let params = Object.assign({},this.newForm)
          params.id=this.activeData.id
          params.name=this.activeData.name
          let url = '/business/business/renew'
            this.$ajax({
            url: url,
            method: 'post',
            data: params
          }).then( data => {
              this.loading = false
              this.$message({
                type: 'success',
                message: '续费成功',
                center: true
              })
              this.$emit('success',data);
          }, error => {
              this.$emit('fail');
              this.loading = false
              this.$message.error(error.msg || '系统错误');
          })
        } else {
          return false;
        }
      });
    },
  },
  created () {
    /*this.initForm()*/
    let params = Object.assign({},this.newForm)
  },
}
</script>